<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P56 3.4.2 【案例】二维数组置换</title>
</head>

<body>
    <script>
        var arr = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l']];
        var res = [];
        for (var i = 0; i < arr[0].length; ++i) {
            res[i] = [];
            for (var j = 0; j < arr.length; ++j) {
                res[i][j] = arr[j][i];
            }
        }
        console.group('转置前：');
        console.log(arr);
        console.groupEnd();
        console.group('转置后：');
        console.log(res);
        console.groupEnd();
    </script>
    <a href="../首页/page03.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>